import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import base from "@src/store/base";

Component({
  options: {
    addGlobalClass: true
  },
  behaviors: [storeBindingsBehavior],
  storeBindings: [{
    store: base,
    fields: ['themeColor', 'themeTitleColor']
  }],
  data: {
    list: [],
    dialogVisible: false,
    resolve: null,
    reject: null
  },
  methods: {
    open(data) {
      let remarkArr = [];
      let couponInstructionArr = [];
      if (data && data.passRemark) {
        data.passRemark.split(/[(\r\n)\n]+/).forEach(v => {
          remarkArr.push({returnString: v, timeString: ""});
        });
      }
      if (data && data.couponInstructionArr) {
        couponInstructionArr = data.couponInstructionArr;
      }
      let list = couponInstructionArr.concat(remarkArr);
      return new Promise((resolve, reject) => {
        this.setData({list: list, dialogVisible: true, resolve: resolve, reject: reject})
      });
    },

    close() {
      this.setData({list: [], dialogVisible: false, resolve: null, reject: null})
    },
    handleStop() {
      return false;
    }
  }
})
